package com.yun.zf.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yun.zf.admin.mapper.CityTempMapper;
import com.yun.zf.admin.service.CityTempService;
import com.yun.zf.common.admin.domain.CityTemp;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author cj
 * @since 2021-05-13
 */
@Service
public class CityTempServiceImpl extends ServiceImpl<CityTempMapper, CityTemp> implements CityTempService {

    @Override
    public List<CityTemp> getCity(List<Long> prov) {
        QueryWrapper<CityTemp> tempQueryWrapper =new QueryWrapper<>();
        tempQueryWrapper.select("DISTINCT code_city ,name_city ,CODE_PROV ,name_prov").lambda().in(CityTemp::getCodeProv,prov).orderByAsc(CityTemp::getCodeProv);
        return baseMapper.selectList(tempQueryWrapper);
    }

    @Override
    public List<CityTemp> getcoun(List<Long> city) {
        QueryWrapper<CityTemp> tempQueryWrapper =new QueryWrapper<>();
        tempQueryWrapper.select("DISTINCT code_coun ,name_coun ,code_city ,name_city,code_prov ,name_prov").lambda().in(CityTemp::getCodeCity,city).orderByAsc(CityTemp::getCodeCity);
        return baseMapper.selectList(tempQueryWrapper);
    }

    @Override
    public List<CityTemp> gettown(List<Long> coun) {
        QueryWrapper<CityTemp> tempQueryWrapper =new QueryWrapper<>();
        tempQueryWrapper.select("DISTINCT code_town ,name_town ,code_coun ,name_coun  ,code_city ,name_city ,code_prov ,name_prov").lambda().in(CityTemp::getCodeCoun,coun).orderByAsc(CityTemp::getCodeCoun);
        return baseMapper.selectList(tempQueryWrapper);
    }
}
